package com.new4net.reactor;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ThreadPoolInitiationDispather extends InitiationDispatcher {
    private ExecutorService executorService ;

    public ThreadPoolInitiationDispather(Subject subject) {
        this(subject, Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()));
    }

    public ThreadPoolInitiationDispather(Subject subject, ExecutorService executorService) {
        super(subject);
        this.executorService = executorService;

    }

    protected void handleEvent(Command command){
        executorService.execute(command);
    }
}
